﻿#ifndef __SS_XML_DB_GROUP_H__
#define __SS_XML_DB_GROUP_H__
#include "thread/ssThreadGroup.h"
#include "ssMySQLClentXml.h"

namespace StarSeeker
{

template<typename DB_THREAD>
class ssXmlDBGroup : public ssThreadGroup<DB_THREAD>
{
public:
	//设置数据库连接
	void Init(const char *pIP, u32	port, const char *pAccount, const char *pPW, const char *pDBName, u32 connectCount=10, u32 threadCount=4)
	{
		m_pool.Init(pIP, port, pAccount, pPW, pDBName, connectCount);
		ssThreadGroup<DB_THREAD>::SetThreadNum(threadCount);
		for (u32 i=0; i<threadCount; ++i)
		{
			ssThreadGroup<DB_THREAD>::m_thread[i].SetMySQLPool(&m_pool);
		}
	}
	//读取配置文件
	bool ReadAllCfg(const char* path)
	{
		if (!m_pool.ReadAllCfg(path))
		{
			return false;
		}
		return m_pool.InitQuery();
	}

private:
	ssMySQLClientXml	m_pool;
};

}
#endif
